package cn.ichiva.tushare.analysis.data.国内宏观.金融;

import cn.ichiva.tushare.analysis.Config;
import cn.ichiva.tushare.analysis.data.国内宏观.国民经济.GDP;
import cn.ichiva.tushare.sdk.tushare.TuClient;
import cn.ichiva.tushare.sdk.tushare.TuDataCacheAble;
import cn.ichiva.tushare.sdk.tushare.entity.TuRequest;

import java.util.HashMap;

/**
 * 货币月度供应量
 *
 * 获取2000年到现在的所有数据
 */
public class CNM extends TuDataCacheAble {

    public CNM(TuClient client) {
        super(client);

        TuRequest request = new TuRequest();
        request.setApi("cn_m");
        request.setDescribe("获取货币供应量之月度数据,单次最大5000，一次可以提取全部数据");

        HashMap<String,String> paramsMap = new HashMap<>();
        paramsMap.put("start_m","200001");
        //paramsMap.put("end_m",DateUtils.lastTUMonthString());
        request.setParams(paramsMap);

        HashMap<String,String> fieldMap = new HashMap<>();
        fieldMap.put("month","月份YYYYMM");
        fieldMap.put("m0","M0（亿元）");
        fieldMap.put("m0_yoy","M0同比（%）");
        fieldMap.put("m0_mom","M0环比（%）");
        fieldMap.put("m1","M1（亿元）");
        fieldMap.put("m1_yoy","M1同比（%）");
        fieldMap.put("m1_mom","M1环比（%）");
        fieldMap.put("m2","M2（亿元）");
        fieldMap.put("m2_yoy","M2同比（%）");
        fieldMap.put("m2_mom","M2环比（%）");
        request.setFieldMap(fieldMap);
        setRequest(request);
    }

    public static void main(String[] args) {
        new CNM(new TuClient(Config.url, Config.token))
                .get().ifPresent(System.out::println);
    }
}
